//
//  workSet.m
//  dataGathering
//
//  Created by apple on 14/11/17.
//  Copyright (c) 2014年 shuili. All rights reserved.
//

#import "workSet.h"

@implementation workSet

-(id)init
{
    self = [super init];
    if (self) {
        _isDeleted = NO;
    }
    return self;
}

-(void)setLocationValues:(double)xCoor :(double)yCoor :(NSString *)string
{
    self.x = xCoor;
    self.y = yCoor;
    _locationString = string;
    
}

-(instancetype)initWithNameAndDesc:(NSString *)name :(NSString *)desc
{
    self = [super init];
    if(self){
        _name = name;
        _worksetDescription = desc;
        _collectedDataList = [[NSMutableArray alloc] initWithCapacity:10];
    }
    return self;
}

-(instancetype)initWithNameAndDescAndUser :(NSString*)name :(NSString*)desc :(NSString*)user
{
    self = [super init];
    if(self){
        _name = name;
        _worksetDescription = desc;
        _collectedDataList = [[NSMutableArray alloc] initWithCapacity:10];
        _creator = user;
    }
    return self;
}

-(void)updateDescWithNewWorkset :(workSet*)newWorkSet
{
    _name = newWorkSet.name;
    _creator = newWorkSet.creator;
    _updateTime = newWorkSet.createTime;
    _locationString = newWorkSet.locationString;
    _worksetDescription = newWorkSet.worksetDescription;
    _isAutoSync = newWorkSet.isAutoSync;
    _isCompleted = newWorkSet.isAutoSync;
    
}

-(BOOL)checkNewCollectedDataName :(NSString*)newDataName
{
    if([_collectedDataList count] > 0){
        for (collectedData *d in _collectedDataList) {
            if([[d name] compare:newDataName] == NSOrderedSame){
                return FALSE;
            }
        }
    }
    return TRUE;
}

-(void)addNewCollectedData :(collectedData*)newData
{
    [_collectedDataList addObject:newData];
}


@end
